dojo.provide 'custom.MyWidget'

# Following modules are going to be retrieved from CDN
dojo.require 'dijit._Widget'
dojo.require 'dijit._Templated'
dojo.require 'dijit.form.Button'

dojo.declare 'custom.MyWidget', [dijit._Widget, dijit._Templated], {
  username: "defaultUser"
  templateString: dojo.cache("", "templates/MyWidget.html")

  baseClass: "myWidgetBase"
  title: ""


  constructor: (args)->
    dojo.safeMixin @, args


#	hidden counter
  _counter: 1
  _firstClicked: false
  onClick: (e)->
    console?.log e
    @titleNode.innerHTML = "#{@title} was clicked"

    if @_firstClicked
      @titleNode.innerHTML += " #{++@_counter} times."
    else
      @titleNode.innerHTML += "!"
      @_firstClicked = true

  postCreate: (e)->
    console?.log "username=#{@username}"
    @titleNode.innerHTML = @title

}
